#include<bits/stdc++.h>
using namespace std;

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    int n,m,L,V;
    cin>>T;
    int cntc=0,cntm=0;
    for(int i=0;i<T;i++){
        cin>>n>>m>>L>>V;
        int d[n],v[n],a[n],dis[n];
        for(int j=0;j<n;j++){
            cin>>d[j]>>v[j]>>a[j];
            dis[j]=(V*V-v[j]*v[j])/(2*a[j]);
            cout<<dis[j];
        }
    }
    cout<<cntc;
    return 0;
}
